package com.huike.xingxing.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.huike.xingxing.R;
import com.huike.xingxing.api.Api;
import com.huike.xingxing.bean.Contact;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import androidx.appcompat.app.AppCompatActivity;

public class AdvisoryDescActivity extends AppCompatActivity {

    private ImageView iv_title_black;
    private TextView tv_title_txt_black;
    private TextView tv_title_txt_content;
    private ImageView iv_title_right_image;
    private TextView tv_title_right_txt;
    private Contact.DataBean dataBean;
    private TextView tv_advisorydesc_title;
    private ImageView tv_advisorydesc_image;
    private TextView tv_advisorydesc_desc;
    private TextView tv_advisorydesc_time;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_advisory_desc);
        EventBus.getDefault().register(this);
        initView();
    }

    @Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
    public void EvenstMas(Contact.DataBean bean) {
        dataBean = new Contact.DataBean();
        dataBean.setTitle(bean.getTitle());
        dataBean.setId(bean.getId());
        dataBean.setCreated_at(bean.getCreated_at());
        dataBean.setMessages(bean.getMessages());
        dataBean.setImage(bean.getImage());
    }


    private void initView() {
        iv_title_black = (ImageView) findViewById(R.id.iv_title_black);
        tv_title_txt_black = (TextView) findViewById(R.id.tv_title_txt_black);
        tv_title_txt_content = (TextView) findViewById(R.id.tv_title_txt_content);
        iv_title_right_image = (ImageView) findViewById(R.id.iv_title_right_image);
        tv_title_right_txt = (TextView) findViewById(R.id.tv_title_right_txt);

        tv_title_txt_content.setText("咨询详细");
        iv_title_black.setVisibility(View.VISIBLE);

        //返回按钮点击
        iv_title_black.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        tv_advisorydesc_title = (TextView) findViewById(R.id.tv_advisorydesc_title);
        tv_advisorydesc_image = (ImageView) findViewById(R.id.tv_advisorydesc_image);
        tv_advisorydesc_desc = (TextView) findViewById(R.id.tv_advisorydesc_desc);
        tv_advisorydesc_time = (TextView) findViewById(R.id.tv_advisorydesc_time);


        Glide.with(AdvisoryDescActivity.this).load(Api.url + dataBean.getImage()).into(tv_advisorydesc_image);
        tv_advisorydesc_title.setText(dataBean.getTitle());
        tv_advisorydesc_desc.setText(dataBean.getMessages());
        tv_advisorydesc_time.setText(dataBean.getCreated_at());
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
